import { getToken } from '../api' // 假设api有获取token逻辑

export const checkLogin = () => {
    return !!localStorage.getItem('token')
}

export const getUserId = () => {
    const token = getToken()
    // 假设获取用户ID逻辑，需根据后端接口调整
    return token ? JSON.parse(atob(token.split('.')[1])).user_id : null
}

export const clearLogin = () => {
    localStorage.removeItem('token')
    localStorage.removeItem('isAdmin')
}